<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    	               "http://www.w3.org/TR/html4/loose.dtd">

<html>
	<head>
		<link href="Standard.css" rel="stylesheet" type="text/css">
	  	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	  	<title>Home</title>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script type="text/javascript">
      var map;
      function initialize() {
        var mapOptions = {
          zoom: 1,
          draggable: false,
          panControl: true,
          center: new google.maps.LatLng(39.504041,-96.956542),
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById('googleMapDiv'),
            mapOptions);
        google.maps.event.addListener(map, 'click', function(event) {
            updateLatLng(event.latLng.lat(), event.latLng.lng());
          });
      }
      
      function updateLatLng(lat, lng) {
    	  document.getElementById('latitudeTextBox').value = lat;
    	  document.getElementById('longitudeTextBox').value = lng;
      }

      google.maps.event.addDomListener(window, 'load', initialize);
      </script>
	</head>
	<body>
		<%@include file="header.jsp" %>
		<div id = "container">
			<div id="admin">
				<div id="newCache">
				<%
				String id = request.getParameter("ID");
				Cache c = stateless.getCache(id);
				%>
					<h2>Edit <%=c.getCacheName()%></h2>
					<!-- The editing/header creation needs to be split up, have the "edit" page be only for the main description
					of the class, then have a separate page to add a new header, and a final separate page to edit a header.
					
					Possibly format the profile page so that a Header associated to a cache will show up indented: Example:
					
					Cache Example 1  Edit  Add Header
						Header 1     Edit
						Header 2     Edit
						Header 3     Edit
						
					Start Tuesday by doing the Add Header section, and being able to create a new header with picture.
					After that, go back to ViewCache page to get headers appearing with their caches,
					then finally move on to editing.
					 -->
					<%
						String name = c.getCacheName();
						String desc = c.getCacheDescription();
						double lat = c.getCacheLatitude();
						double lon = c.getCacheLongitude();
					%>
					
					
					<form type="multipart/form-data" method="post" action="Controller?do=editCache&id=<%=c.getCacheId()%>">
				 		<label class="adminLabel">CacheName: </label><input name="cacheName" class="adminTextBox" type="text" value="<%=name%>"/><br class="clearBoth"/>
				 		<label class="adminLabel">Description: </label><textarea name="cacheDesc" class="adminTextAreaBox"><%=desc%></textarea><br class="clearBoth"/>
				 		<label class="adminLabel">Latitude: </label><input name="cacheLat" class="adminTextBox" type="text" id="latitudeTextBox" value="<%=lat%>"/><br class="clearBoth"/>
				 		<label class="adminLabel">Longitude: </label><input name="cacheLon" class="adminTextBox" type="text" id="longitudeTextBox" value="<%=lon%>"/><br class="clearBoth"/>
				 		<div id="googleMapDiv">
				 		</div>
				 		<br class="clearBoth"/>
				 		<input type="submit" value="Update">
				 	</form>
			 	</div>
		
			 	<br class="clearBoth"/>
			 </div>
		</div>
		<div id="footer"></div>
	</body>
</html> 